/**
 * Configure and register global directives
 */
// import { setupPermissionDirective } from './permission';
// import { setupLoadingDirective } from './loading';

// 限制数据数值
import inputLimit from '../directives/inputLimit/index.js'
// 自定义全局点击空白处组件
import clickoutside from '../directives/clickoutside/index.js'

import permission from '../directives/permission/index.js'
import empty from '../directives/empty/index.js'
import debounce from './clickDebounce/index.js'

/** 懒加载图片 */
import VueSrc from '../directives/src/index.js'
import scrollx from '../directives/scrollx/index.js'

export function setupGlobDirectives(app) {
  // setupPermissionDirective(app);
  // setupLoadingDirective(app);

  app.directive('src', VueSrc)
  app.directive('scrollx', scrollx)

  app.use(inputLimit)


  app.directive('elclickoutside', clickoutside)

  app.directive('permission', permission)

  // app.use(empty)
  app.directive("empty",empty)

  app.use(debounce)
}





/**
 * Global authority directive
 * Used for fine-grained control of component permissions
 * @Example v-auth="RoleEnum.TEST"
 */
// import type { App, Directive, DirectiveBinding } from 'vue';
//
// import { usePermission } from '/src/hooks/web/usePermission';
//
// function isAuth(el: Element, binding: any) {
//   const { hasPermission } = usePermission();
//
//   const value = binding.value;
//   if (!value) return;
//   if (!hasPermission(value)) {
//     el.parentNode?.removeChild(el);
//   }
// }
//
// const mounted = (el: Element, binding: DirectiveBinding<any>) => {
//   isAuth(el, binding);
// };
//
// const authDirective: Directive = {
//   mounted,
// };
//
// export function setupPermissionDirective(app: App) {
//   app.directive('auth', authDirective);
// }
//
// export default authDirective;
